; Music of Tut's Pyramid (1986) (Artic Software)
; Ripped by Megachur the 19/03/2009

; Need System Vectors

	write "TUT'SPYR.BIN"

music_date_rip	equ &
music_adr	equ &9b53
first_theme	equ 0
last_theme	equ 0	; 0 -> 0

	read "music_header_v1_0.asm"

;
.real_init_music
;
	ld hl,l9c65
	ld (l9c61),hl
	ld hl,l9d22
	ld (l9c63),hl
	ld a,#ff
	ld (l9c60),a
	ret
	ld hl,l9c16
	call #bcec
	ret
.l9b6c
	call l9b73
	call l9b92
	ret
.l9b73
	ld a,#02
	call #bcad
	and #07
	cp #04
	ret nz
	ld hl,(l9c61)
	ld c,(hl)
	ld a,c
	cp #ff
	jr z,l9bac
	inc hl
	ld b,(hl)
	inc hl
	ld d,(hl)
	inc hl
	ld (l9c61),hl
	call l9bb9
	ret
.l9b92
	ld a,#04
	call #bcad
	and #07
	cp #04
	ret nz
	ld hl,(l9c63)
	ld c,(hl)
	inc hl
	ld b,(hl)
	inc hl
	ld d,(hl)
	inc hl
	ld (l9c63),hl
	call l9bd2
	ret
.l9bac
	ld hl,l9c65
	ld (l9c61),hl
	ld hl,l9d22
	ld (l9c63),hl
	ret
.l9bb9
	ld a,c
	ld (l9bee),a
	ld a,b
	ld (l9bef),a
	ld e,#00
	ld a,d
	ld (l9bf2),a
	ld a,e
	ld (l9bf3),a
	ld hl,l9beb
	call #bcaa
	ret
.l9bd2
	ld a,c
	ld (l9bf7),a
	ld a,b
	ld (l9bf8),a
	ld e,#00
	ld a,d
	ld (l9bfb),a
	ld a,e
	ld (l9bfc),a
	ld hl,l9bf4
	call #bcaa
	ret
.l9bf2 equ $ + 7
.l9bef equ $ + 4
.l9bee equ $ + 3
.l9beb
	db #02,#0f,#0f,#00,#00,#00,#07,#00
.l9bf8 equ $ + 5
.l9bf7 equ $ + 4
.l9bf4 equ $ + 1
.l9bf3
	db #00,#04,#0f,#0f,#00,#00,#00,#05
.l9bfc equ $ + 1
.l9bfb
	db #00,#00
	ld hl,l9c1c
	ld bc,#8000
	ld de,l9c23
	call #bcef
	ld hl,l9c16
	ld bc,#0005
	ld de,#0005
	call #bce9
	ret
.l9c1c equ $ + 6
.l9c16
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00,#00
.l9c23
	push af
	push bc
	push de
	push hl
	push ix
	push iy
	call l9c37
	pop iy
	pop ix
	pop hl
	pop de
	pop bc
	pop af
	ret
;
.play_music
.l9c37
;
	ld a,(l9c60)
	or a
	jr nz,l9c4d
	ld ix,l9ebb
	ld a,(ix+#05)
	call l9e48
	ret z
	ld a,#ff
	ld (l9c60),a
.l9c4d
	ld ix,l9ebb
	ld a,(ix+#06)
	call l9e48
	jp z,l9b6c
	ld a,#00
	ld (l9c60),a
	ret
.l9c60
	db #ff
.l9c63 equ $ + 2
.l9c61
	dw l9c65,l9d22
.l9c65
	db #ef,#00,#60,#fd,#00,#30,#1c,#01
	db #0c,#fd,#00,#0c,#1c,#01,#18,#3f
	db #01,#c0,#66,#01,#60,#92,#01,#30
	db #c3,#01,#0c,#92,#01,#0c,#c3,#01
	db #0c,#92,#01,#0c,#de,#01,#90,#ef
	db #00,#30,#3f,#01,#60,#66,#01,#18
	db #3f,#01,#18,#1c,#01,#0c,#fd,#00
	db #0c,#1c,#01,#18,#3f,#01,#90,#3f
	db #01,#18,#3f,#01,#18,#fd,#00,#48
	db #ef,#00,#18,#d5,#00,#18,#b3,#00
	db #18,#c9,#00,#18,#d5,#00,#18,#ef
	db #00,#90,#ef,#00,#18,#ef,#00,#18
	db #d5,#00,#30,#b3,#00,#30,#96,#00
	db #30,#9f,#00,#30,#b3,#00,#90,#b3
	db #00,#18,#9f,#00,#18,#be,#00,#48
	db #be,#00,#18,#b3,#00,#18,#9f,#00
	db #18,#b3,#00,#30,#be,#00,#90,#be
	db #00,#30,#b3,#00,#18,#b3,#00,#30
	db #9f,#00,#18,#7f,#00,#18,#96,#00
	db #18,#9f,#00,#18,#b3,#00,#18,#be
	db #00,#90,#ef,#00,#30,#e1,#00,#60
	db #c9,#00,#30,#e1,#00,#0c,#c9,#00
	db #0c,#e1,#00,#18,#ef,#00,#90,#3f
.l9d22 equ $ + 5
	db #01,#30,#ff,#ff,#ff,#bc,#03,#30
	db #7e,#02,#18,#7e,#02,#18,#bc,#03
	db #30,#7e,#02,#18,#7e,#02,#18,#bc
	db #03,#30,#7e,#02,#18,#7e,#02,#18
	db #bc,#03,#30,#7e,#02,#30,#bc,#03
	db #30,#7e,#02,#18,#7e,#02,#18,#bc
	db #03,#30,#7e,#02,#18,#7e,#02,#18
	db #bc,#03,#18,#53,#03,#18,#2e,#02
	db #18,#a4,#02,#18,#5a,#02,#18,#18
	db #02,#18,#de,#01,#18,#aa,#01,#18
	db #7b,#01,#30,#aa,#01,#18,#de,#01
	db #18,#18,#02,#18,#5a,#02,#18,#cc
	db #02,#18,#cc,#02,#18,#bc,#03,#30
	db #7e,#02,#18,#7e,#02,#18,#bc,#03
	db #30,#7e,#02,#18,#7e,#02,#18,#fc
	db #04,#30,#7e,#02,#18,#7e,#02,#18
	db #fc,#04,#30,#7e,#02,#18,#7e,#02
	db #18,#bc,#03,#30,#7e,#02,#18,#7e
	db #02,#18,#bc,#03,#30,#7e,#02,#18
	db #7e,#02,#18,#cc,#02,#18,#24,#03
	db #18,#86,#03,#30,#bc,#03,#18,#86
	db #03,#18,#24,#03,#30,#24,#03,#30
	db #5a,#02,#18,#5a,#02,#18,#86,#03
	db #30,#5a,#02,#18,#7e,#02,#18,#bc
	db #03,#30,#7e,#02,#18,#7e,#02,#18
	db #86,#03,#30,#5a,#02,#18,#5a,#02
	db #18,#bc,#03,#30,#7e,#02,#18,#7e
	db #02,#18,#bc,#03,#30,#7e,#02,#18
	db #7e,#02,#18,#86,#03,#30,#86,#03
	db #18,#24,#03,#18,#cc,#02,#30,#24
	db #03,#18,#86,#03,#18,#bc,#03,#30
	db #7e,#02,#18,#7e,#02,#18,#bc,#03
	db #30,#7e,#02,#18,#7e,#02,#18,#86
	db #03,#30,#5a,#02,#18,#5a,#02,#18
	db #53,#03,#30,#5a,#02,#18,#5a,#02
	db #18,#bc,#03,#30,#7e,#02,#18,#7e
	db #02,#18,#bc,#03,#30,#7e,#02,#18
	db #7e,#02
	db #18
.l9e48
	push af
	ld a,(#b637)
	and #a0
	ld c,a
	pop af
	ld hl,#b635
	call l9e58
	and (hl)
	ret
.l9e58
	push de
	push af
	and #f8
	rrca
	rrca
	rrca
	ld e,a
	ld d,#00
	add hl,de
	pop af
	push hl
	ld hl,l9ed1
	and #07
	ld e,a
	add hl,de
	ld a,(hl)
	pop hl
	pop de
	ret
.l9e70
	bit 6,(iy+#17)
	jr nz,l9e70
	ret
	call #bbc0
	ld de,#008a
	ld hl,#0000
	jp #bbf9
	db #00,#00,#00,#00,#50,#c3,#50,#c3
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#d2,#9d,#00,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#00,#00
.l9ebb
	db #45,#22,#1b,#43,#2c,#2f,#10,#61
	db #6f,#70,#71,#68,#2a,#2a,#20,#20
.l9ed1 equ $ + 6
	db #00,#00,#00,#00,#00,#00,#01,#02
	db #04,#08,#10,#20,#40,#80,#f3,#03
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#0f,#01,#81,#01,#01,#90,#01
	db #00,#00,#ff,#ff,#81,#02,#02,#14
	db #00,#00,#00,#fd,#ff,#81,#03,#03
	db #e8,#03,#00,#0f,#46,#00,#81,#04
	db #04,#14,#00,#00,#00,#f6,#ff,#81
	db #03,#05,#f4,#01,#01,#0f,#01,#00
	db #81,#03,#06,#c8,#00,#00,#0f,#32
	db #00,#81,#07,#07,#14,#00,#00,#00
	db #fd,#ff,#81,#08,#08,#c8,#00,#00
	db #00,#28,#00,#81,#09,#09,#0a,#00
	db #00,#00,#14,#00,#81,#0a,#0a,#f4
	db #01,#00,#00,#fd,#ff,#81,#08,#0b
	db #e8,#03,#00,#00,#1e,#00,#81,#0c
	db #0c,#58,#02,#00,#00,#3c,#00,#81
	db #0d,#0d,#c8,#00,#0a,#0f,#fc,#ff
	db #81,#0e,#00,#00,#00,#01,#00,#64
	db #00,#21,#d3,#9f,#06,#10,#c5,#50
	db #7e,#23,#47,#4f,#3e,#10,#92,#e5
	db #cd,#32,#bc,#e1,#c1,#10,#ef,#c9
	db #00,#18,#0f,#06,#14,#1a,#0e,#11
	db #12,#0a,#03,#09,#19,#13,#0d,#0c
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00,#00
;
.init_music	; added by Megachur
;
	ld hl,evt_bloc
	ld bc,#8100
	ld de,play_music
	jp #bcd7	; call play_music every CRT interrupt
evt_bloc
	db #00,#00,#00,#00,#00,#00
	db #00,#00,#00
;
.game_name
	db "Tut's Pyramid",0
.game_year
	db "1986",0
.game_publisher
	db "Artic Software",0
.music_author
	db "",0
.music_comment
	db "",0

	read "music_end_v1_0.asm"
